<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>823680621@qq.com</title>
	<style>
		#box{
			width: 800px;
			height: 400px;
			border:1px solid gray;
			margin:100px auto;
		}
		#nav{
			width: 200px;
			height: 300px;
			border:1px dotted red;
			float: left;
		}
		#main{
			width: 500px;
			height: 400px;
			border:2px solid blue;
			background: #dddddd;
			float: right;
		}
		li{list-style: none;
			
			height: 50px;
			width: 100%;
			background:#FFEFD5;
			border:1px solid gray;
			line-height: 50px;
			text-align: center; 
		}
	</style>
</head>
<body>
	<div id="box">
		<div id="nav">
		</div>
		<div id="main"></div>
	</div>
</body>
<script src="data.js"></script>
<script >
	var str='';
	for(var key in data){
		str+="<li data-name="+key+">"+key+"</li>";
	}
	nav.innerHTML=str;


var oli=document.querySelectorAll("li");
for(var i=0;i<oli.length;i++){
	oli[i].onclick=function(){
		main.innerHTML=data[this.dataset.name];
		if (window.history&&window.history.pushState) {
			window.history.pushState(this.dataset.name,'Zero Three','#ZS='+decodeURI(this.dataset.name));
		}
	}
}
//监听历史
window.onpopstate=function(e){
	if (e.state) {
	main.innerHTML=data[e.state]
	}
}
</script>
</html>